#!/usr/bin/env python


import sys
sys.path.append('lib/DataPort')

import DataPort
import xml.dom.minidom

inputFile = None

if sys.stdin.isatty() is False:
    inputFile = sys.stdin
elif len(sys.argv) > 1:
    if sys.argv[1] == "-":
        inputFile = sys.stdin
    else:
        inputFile = open(sys.argv[1], 'r')

if inputFile is not None:
    port = DataPort.DataPort()
    port.load_file(inputFile)
    
    print port
    pass
else:
    #TODO: print usage
    
    print """Usage: program.py [OPTION]... [SOURCE_FILE]
Load the pyDataPort import definition from SOURCE_FILE.

Mandatory arguments to long options are mandatory for short options too.
  -g, --go              Start the import immediately after successfully loading
                        from [SOURCE_FILE]
"""
    
    pass
